package org.dna.opdracht4;

public class Edge<T> {
	private Vertex<T> to = null;
	private Vertex<T> from = null;
	private int cost = 0;
 
	public Edge(Vertex<T> from, Vertex<T> to, int cost) {
		if(from == null || to == null) {
			throw new NullPointerException("Both 'from' and 'to' cannot be NULL");
		}
		
		this.from = from;
		this.to = to;
		this.cost = cost;
	}
	
	public Edge(Edge<T> edge) {
		this(edge.getFrom(), edge.getTo(), edge.getCost());
	}
	
	public Vertex<T> getTo() {
		return to;
	}

	public Vertex<T> getFrom() {
		return from;
	}
	
	public int getCost() {
		return cost;
	}
	
	@Override
	public String toString() {
		StringBuilder builder = new StringBuilder();
		builder.append("Edge: [");
		builder.append(from.getValue());
		builder.append("] -> [");
		builder.append(to.getValue());
		builder.append("] = ");
		builder.append(cost);
		
		return builder.toString();
	}
}